// <copyright file="EasyWebApp.cs" company="<Customer Name>">This is a "work-for-hire". or Copyright (C) 2010 MicroCODE Incorporated Troy, MI</copyright><author><Class Author's Name></author>

/*
 *      Title:    <Class Description>
 *      Module:   ClassTemplate (<Namespace>:ClassTemplate.cs)
 *      Project:  <Project Name>
 *      Customer: <Customer Name>
 *      Facility: MicroCODE Incorporated
 *      Date:     <Class Creation Date>
 *      Author:   <Class Author's Name>
 * 
 * 
 * 
 *  
 *      MODIFICATIONS:
 *      --------------
 *
 *  Date:         By-Group:   Rev:     Description:
 *
 *  DD-Mmm-YYYY   XYZ-GROUP  {0001}    Describe reason for creating or modifying class... 
 * 
 * 
 * 
 */
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using Org.EasyWeb.Cache;
using Org.EasyWeb.Data;
using Org.EasyWeb.Sys;
using Org.EasyWeb.Xml;

namespace Org.EasyWeb.Web
{
    public class ApplicationGlobal : IAppGlobal
    {
        // Fields
        private Assembly fAppAssembly;
        private string fAppName;
        private string fAppPath;
        private CachesHashTable fCaches;
        private string fConnectionString;
        private string fErrorPath;
        private bool fIsShowException;
        private RegsCollection fRegsCollection;

        // Methods
        public ApplicationGlobal()
        {
            this.Initialize();
            this.fConnectionString = AppSettings.Current.ConnectionString;
            this.fErrorPath = AppSettings.Current.ErrorPath;
            this.fIsShowException = AppSettings.Current.IsShowException;
            this.fAppPath = AppSettings.Current.AppPath;
            this.fAppName = string.Empty;
        }

        private void GetAssembly(Assembly ass)
        {
            this.fAppAssembly = ass;
            string codeBase = this.fAppAssembly.CodeBase;
            int num = codeBase.LastIndexOf('/');
            this.fAppPath = codeBase.Substring(0, num + 1);
            this.fAppName = codeBase.Substring(num + 1);
            this.fAppName = this.fAppName.Substring(0, this.fAppName.LastIndexOf('.'));
        }

        private void Initialize()
        {
            this.fCaches = new AppCachesHashTable();
        }

        public void SearchAttributes()
        {
            string attType = AppSettings.Current.AppPath;
            this.fRegsCollection.Initialize(attType);
            XsltTemplates.Current.ReadXslt(Path.Combine(attType, "Xslt"));
        }

        // Properties
        public CachesHashTable Caches
        {
            get
            {
                return this.fCaches;
            }
        }

        public RegsCollection RegsCollection
        {
            get
            {
                return this.fRegsCollection;
            }
            set
            {
                this.fRegsCollection = value;
            }
        }
    }
}
